package com.itheima.servcie;

import cn.hutool.core.convert.Convert;
import com.itheima.bean.CodeBean;
import com.itheima.dbservice.QuestionServiceApi;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

@Service
public class QuestionService {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @DubboReference
    private QuestionServiceApi questionServiceApi;
    /**
     * 添加问题
     * @param content
     * @return
     */
    public ResponseEntity addQuestion(String content) {
        //获取id
        Long uid = Convert.toLong(stringRedisTemplate.opsForValue().get(CodeBean.ID));
        //调用api接口
        questionServiceApi.addQuestion(uid,content);
        //添加成功
        return ResponseEntity.ok("添加成功!");
    }
}
